﻿<script type="text/javascript" src="${base}/scripts/base/stringOperate.js"></script>
<script type="text/javascript">
    $(function () {

        $("#cght_into_grid").edatagrid({
            url:$.webPath() + "/htgl/cghtgl/bgjjhzSearchList",
            fitColumns:true,
            singleSelect:true,
            toolbar:"#toolbar_cghtinto_search",
            fit:true,
            pagination:true,
            checkOnSelect:false,
            selectOnCheck:false,
            pageNumber:1,
            rownumbers:true,
            columns:[
                [
                    {field:'bm', title:'计划编码', width:$(this).width() * 0.2},
//                    {field:'jyjg.qc', title:'物流园', width:$(this).width() * 0.2},
                    {field:'sm', title:'计划说明', width:$(this).width() * 0.6},
                    {field:'jhsj', title:'计划时间', width:$(this).width() * 0.1},
                    {field:'createUser.xm', title:'计划员', width:$(this).width() * 0.1}
                ]
            ],
            onSelect:function (rowIndex, rowData) {
                selectedData(rowData.id);
                $("#ljId").val(rowData['lj.id']);
                $("#jhId").val(rowData.id);
            }
        });

        function selectedData(id) {
            $("#search_cght_selected_grid").edatagrid({
                url:$.webPath() + "/jhgl/bgjhlr/bgjhLists?id=" + id,
                fitColumns:true,
                rownumbers:true,
                singleSelect:true,
                pageNumber:1,
                fit:true,
                columns:[
                    [
                        {field:'bm', title:'计划编码', width:$(this).width() * 0.2},
//                        {field:'jyjg.qc', title:'物流园', width:$(this).width() * 0.2},
                        {field:'sm', title:'计划说明', width:$(this).width() * 0.6},
                        {field:'jhsj', title:'计划时间', width:$(this).width() * 0.1},
                        {field:'createUser.xm', title:'计划员', width:$(this).width() * 0.1}
                    ]
                ]
            });
            $("#hzjhmx").edatagrid({
                url:$.webPath() + "/jhgl/bgjhlr/bgjhhzmxdetail?hz=1&id=" + id,
                fitColumns:true,
                rownumbers:true,
                singleSelect:true,
                pageNumber:1,
                pagination:true,
                fit:true,
                columns:[
                    [
                        {title:'物资编码', field:'wzgg.code', align:'center', width:150},
                        {title:'物资名称', field:'wzgg.name', align:'center', width:150},
                        {title:'材质', field:'wzgg.cz', align:'center', width:150},
                        {title:'型号规格', field:'wzgg.ggxh', align:'center', width:150},
//                        {title:'图号', field:'wzgg.th', align:'center', width:60},
                        {title:'单位', field:'dw', align:'center', width:60},
                        {title:'计划件数', field:'jhjs', align:'right', width:80},
                        {title:'计划重量', field:'jhsl', align:'right', width:80},
                        {title:'到货日期', field:'dhrq', align:'center', width:150},
                        {title:'牌号', field:'ph', align:'center', width:100},
                        {title:'设备材料', field:'sbcl', align:'center', formatter:function (value, row, index) {
                            if (value == 'cl') {
                                return '材料';
                            } else if (value == 'sb') {
                                return '设备';
                            }
                        }, width:140},
                        {title:'备注', field:'bz', align:'center', width:150}
                    ]
                ]
            });
        }


        $("#btn_cghtinto_search_init").click(function () {
            $('#cght_into_grid').edatagrid({
                url:$.webPath() + "/htgl/cghtgl/bgjjhzSearchList",
                pageNumber:1,
                queryParams:{
                    sm:$("[name='cghtjhsm']").val(),
                    bm:$("[name='cghtjhbm']").val(),
                    startDate:$("[name='cghtjhsj_start']").val(),
                    endDate:$("[name='cghtjhsj_end']").val()
                },
                columns:[
                    [
                        {field:'bm', title:'计划编码', width:$(this).width() * 0.2},
//                        {field:'jyjg.qc', title:'物流园', width:$(this).width() * 0.2},
                        {field:'sm', title:'计划说明', width:$(this).width() * 0.6},
                        {field:'jhsj', title:'计划时间', width:$(this).width() * 0.1},
                        {field:'createUser.xm', title:'计划员', width:$(this).width() * 0.1}
                    ]
                ],
                onSelect:function (rowIndex, rowData) {
                    selectedData(rowData.id);
                    $("#ljId").val(rowData['lj.id']);
                    $("#jhId").val(rowData.id);
                }
            });
        });

    })

</script>
<div class="easyui-layout" data-options="fit:true">
    <input type="hidden" id="ljId"/>
    <input type="hidden" id="jhId"/>

    <div data-options="region:'north',split:true" style="height:375px">
        <div id="toolbar_cghtinto_search" style="height:auto">
            <div class="textcon">
                <table class="tb" style="margin-left: 12px;">
                    <tr>
                        <th>计划编码：</th>
                        <td><input name="cghtjhbm" type="text" class="input-text" value=""/></td>
                        <th>计划说明：</th>
                        <td><input name="cghtjhsm" type="text" class="input-text" value=""/></td>
                        <th>计划时间：</th>
                        <td><input name="cghtjhsj_start" type="text" class="easyui-datebox" value=""/>至<input
                                name="cghtjhsj_end" type="text" class="easyui-datebox" value=""/></td>
                        <td style=" padding-left:5px;">
                            <input id="btn_cghtinto_search_init" type="button" value=""
                                   class="submit"/>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <table id="cght_into_grid"></table>
    </div>
    <div data-options="region:'center'">
        <div class="easyui-tabs" fit="true">
            <div title="计划明细" fit="true">
                <table id="hzjhmx">
                </table>
            </div>
            <div title="汇总计划" fit="true">
                <table id="search_cght_selected_grid">
                </table>
            </div>
        </div>
    </div>
</div>